package com.jinbei.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinbei.domain.Logs;
import com.jinbei.mapper.LogsMapper;
import com.jinbei.service.LogsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zflu
 * Created by lucky on 2018/7/10.
 */
@Service
public class LogsServiceImpl implements LogsService{

    private final Logger logger = LoggerFactory.getLogger(LogsServiceImpl.class);

    @Autowired
    private LogsMapper logsMapper;

    /**
     * @author zflu
     * @Description  日志新增
     * @date 2018/7/10 16:03
     * @param logs
     * @return int
     */
    @Override
    public int insertLogs(Logs logs) throws Exception {
        return logsMapper.insertLogs(logs);
    }

    /**
     * @author zflu
     * @Description  日志修改
     * @date 2018/7/10 16:03
     * @param logs
     * @return int
     */
    @Override
    public int updateLogs(Logs logs) throws Exception {
        return logsMapper.updateLogs(logs);
    }

    /**
     * @author zflu
     * @Description 根据日志id删除日志
     * @date 2018/7/10 16:03
     * @param id
     * @return int
     */
    @Override
    public int deleteLogsById(int id) throws Exception {
        return logsMapper.deleteLogsById(id);
    }

    /**
     * @author zflu
     * @Description 根据日志id查询日志
     * @date 2018/7/10 16:03
     * @param id
     * @return com.jinbei.domain.Logs
     */
    @Override
    public Logs queryLogsById(int id) throws Exception {
        return logsMapper.queryLogsById(id);
    }

    /**
     * @author zflu
     * @Description  日志记录分页列表
     * @date 2018/7/12 9:17
     * @param pageNum, pageSize
     * @return com.github.pagehelper.PageInfo
     */
    @Override
    public PageInfo queryLogsPage(int pageNum, int pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        List<Logs> logs = logsMapper.queryLogsPage();
        return new PageInfo(logs);
    }
}
